﻿@{
    ViewBag.Title = "Home Page";
}
@model Pagination<CW_ArticleView>

<h3 class="CN-HeadTitle">@ViewBag.MenuName</h3>    
<ul class="list-group CN-ArticleList">

    @foreach (var item in Model)
    {
        <li class="list-group-item">
            <a class="focus" href="@Url.Action("detail", new { id=item.Article.ArticleId})">
                @if (!string.IsNullOrEmpty(item.Article.Thumb))
                {
                    <img class="thumb" src="@Url.Content("~/images/logo")/@item.Article.Thumb" />
                }
                else
                {
                    <img class="thumb" src="@Url.Action("GetAutoImgByTxt", "ValidateCode", new { txt = item.MenuName })" />
                }
            </a>
            <header>
                @if (!string.IsNullOrEmpty(item.MenuName))
                {
                    <a class="noteTag">@item.MenuName</a>
                }

                <h2>
                    <a class="title" href="@Url.Action("detail", new { id = item.Article.ArticleId })">@item.Article.Title</a>
                </h2>
            </header>
            <p class="meta">
                <span><i class="fa fa-clock-o"></i>@Convert.ToDateTime(item.Article.CreateDate).ToString("yyyy-MM-dd")</span>
                <span class="pv"><i class="fa fa-eye"></i>阅读(@item.Article.PV)</span>
                <a class="pc" href="@Url.Action("detail", new { id = item.Article.ArticleId })#comments"><span><i class="fa fa-comments-o"></i>评论(@item.Article.CommentCount)</span></a>
            </p>
            <p class="note">
                @item.Article.Abstract
            </p>
        </li>
    }

</ul>

@if (Model.TotalPages > 0)
{
    <nav>
        <ul class="pagination">
            <li>
                @Html.ActionLink("<<", "ArticleType", new { page = 0 })
            </li>
            @for (int i = 0; i < Model.TotalPages; i++)
            {
                if (i == Model.PageIndex)
                {
                    <li class="active">
                        @Html.ActionLink((i + 1).ToString(), "ArticleType", new { page = i })
                    </li>
                }
                else
                {
                    <li>
                        @Html.ActionLink((i + 1).ToString(), "ArticleType", new { page = i })
                    </li>
                }
            }
            <li>
                @Html.ActionLink(">>", "ArticleType", new { page = Model.TotalPages - 1 > 0 ? Model.TotalPages - 1 : 0 })
            </li>
        </ul>
    </nav>

}

